package nl.sportan.samenloop.communication.flickr;

import java.io.IOException;

import org.json.JSONException;

import nl.sportan.samenloop.communication.PhotoListTarget;

import com.gmail.yuyang226.flickr.Flickr;
import com.gmail.yuyang226.flickr.FlickrException;
import com.gmail.yuyang226.flickr.photos.PhotoList;
import com.gmail.yuyang226.flickr.photosets.PhotosetsInterface;

public class PhotoListRetriever implements Runnable {

		private PhotoListTarget target;
		private String photosetId;
		
		//private final static String TAG = "PhotoListRetriever";
		
		public PhotoListRetriever(String photosetId, PhotoListTarget target) {
			this.target = target;
			this.photosetId = photosetId;
		}
		
		
		public void run() {
			Flickr f = new Flickr(FlickrConstants.APIKEY);

			PhotosetsInterface psi = f.getPhotosetsInterface();
			PhotoList list;
			try {
				list = psi.getPhotos(photosetId, 100, 0);
				target.setPhotoList(list);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (FlickrException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}

	}